<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>

<script type="text/javascript">

var PUB_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmkAHsRwURV2qln/iC0dawE65vrfEsdX4PExr1HQ0ramVjcoCcg3JC5LwwwZqm38E4TuBL8bc502Q8zBYz55ICdztY4Jql+0cpRl4yaC8JjBqGRBKAN4Rpjei2qLThI8/+gXCaoGu1gNhH84EQNybXNUful8aa+GNQqAcIfraesf/SFFdfdEVWvTkZWh4hkziuVJOhp1lKxOwvDx5DGU2tJBu1VIBKbZXmsptDmkVorOzkIWgTihSJCEFVdJ6dGdU+PAs6ASE0dvBjD9bQO9gaHBvE7pXszsVAL8iCJ8CbSasY3mjLcBYd08SLzipozW5PlEqX2ZoDZ0N2xo3B167mQIDAQAB";



function base64ToArrayBuffer(base64){
	var bin = atob(base64);
	var arr = new Uint8Array(bin.length);
	arr.forEach(function(v, i, a){
		a[i] = bin.charCodeAt(i);
	});
	return arr.buffer;
}

function arrayBufferToBase64(arrayBuffer){
	var byteArray = new Uint8Array(arrayBuffer);
	var byteStr = '';
	byteArray.forEach(function(v){
		byteStr += String.fromCharCode(v);
	});
	return btoa(byteStr);
}

var publicKey = base64ToArrayBuffer(PUB_KEY);
crypto.subtle.importKey(
	'spki',
	publicKey,
	{
		name: "RSA-OAEP",
		hash: {
			name: "SHA-1"
		}
	},
	false, ["encrypt"]
	).then(function(pubKey){
		crypto.subtle.encrypt({
			name: "RSA-OAEP"
		}, pubKey, new Uint8Array([97,98,99]).buffer)
		.then(function(encrypted){
			console.log(arrayBufferToBase64(encrypted))
		})
	})
;




</script>

</body>
</html>